def fun(nums):
    result=[]
    path=[]
    used=[False]*len(nums)
    def backtracking(nums,used):
        if len(path)==len(nums):
            result.append(path[:])
            return
        for i in range(len(nums)):
            if used[i]==True:
                continue
            used[i]=True
            path.append(nums[i])
            backtracking(nums,used)
            used[i]=False
            path.pop()
    backtracking(nums,used)
    return result
res=fun([1,2,3])
print(res)